package org.robot.scm;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.robot.scm.infra.ProxyLoaderHelper;
import org.robot.scm.platform.AbstractMonitor;
import org.robot.scm.platform.AbstractRegistry;
import org.robot.scm.platform.AbstractSchedule;
import org.robot.scm.platform.server.ScmHttpServer;
import org.robot.scm.platform.socks5.Socks5Server;
import org.robot.scm.platform.wxrobot.AbstractConnector;

@Slf4j
public class ScmMonitorRunner {

    static final ExecutorService executor = Executors.newFixedThreadPool(10);

    public static void main(String[] args) {

        // 加载配置
        AbstractMonitor.cfg(args[0]);

        // 监控程序启动
        executor.submit(AbstractMonitor::start);

        // 启动系统代理
        executor.submit(ProxyLoaderHelper::start);

        // SOCKET监听
        executor.submit(AbstractConnector::start);

        // 启动HTTP服务
        executor.submit(ScmHttpServer::start);

        // 定时任务
        executor.submit(AbstractSchedule::start);

        // 启动应用HOOK
        executor.submit(AbstractRegistry::start);

        // 启动socks5代理
        executor.submit(Socks5Server::registry);
    }

}
